import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '法规编号',
    align:"center",
    dataIndex: 'number'
  },
  {
    title: '文件名称',
    align:"center",
    dataIndex: 'name'
  },
  {
    title: '法律法规分类',
    align:"center",
    dataIndex: 'type_dictText'
  },
  {
    title: '强制程度',
    align:"center",
    dataIndex: 'coerciveDegree_dictText'
  },
  {
    title: '发布机构',
    align:"center",
    dataIndex: 'issuingAuthority'
  },
  {
    title: '发布日期',
    align:"center",
    sorter: true,
    dataIndex: 'releaseDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '启用日期',
    align:"center",
    sorter: true,
    dataIndex: 'startDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '废止日期',
    align:"center",
    sorter: true,
    dataIndex: 'annulmentDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '是否现行',
    align:"center",
    dataIndex: 'currentOrNot_dictText'
  },
  {
    title: '附件',
    align:"center",
    dataIndex: 'doc',
  },
  {
    title: '复查时间',
    align:"center",
    dataIndex: 'reviewDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '辨识人',
    align:"center",
    dataIndex: 'recognizePeople_dictText'
  },
  {
    title: '辨识日期',
    align:"center",
    dataIndex: 'recognizeDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '来源',
    align:"center",
    dataIndex: 'source'
  },
  {
    title: '适用部门',
    align:"center",
    dataIndex: 'applicableDepartment_dictText'
  },
  {
    title: '状态',
    align:"center",
    dataIndex: 'status_dictText'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "法规编号",
    field: "number",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "文件名称",
    field: "name",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "法律法规分类",
    field: "type",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"lawsRegulationsType"
    },
    //colProps: {span: 6},
  },
  {
    label: "强制程度",
    field: "coerciveDegree",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"coerciveDegree"
    },
    //colProps: {span: 6},
  },
  {
    label: "发布日期",
    field: "releaseDate",
    component: 'RangePicker',
    componentProps: {
      valueType: 'Date',
    },
    //colProps: {span: 6},
  },
  {
    label: "是否现行",
    field: "currentOrNot",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"yn"
    },
    //colProps: {span: 6},
  },
  {
    label: "辨识日期",
    field: "recognizeDate",
    component: 'RangePicker',
    componentProps: {
      valueType: 'Date',
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '法规编号',
    field: 'number',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入法规编号!'},
      ];
     },
  },
  {
    label: '文件名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入文件名称!'},
      ];
     },
  },
  {
    label: '法律法规分类',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"lawsRegulationsType"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入法律法规分类!'},
      ];
     },
  },
  {
    label: '强制程度',
    field: 'coerciveDegree',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"coerciveDegree"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入强制程度!'},
      ];
     },
  },
  {
    label: '发布机构',
    field: 'issuingAuthority',
    component: 'Input',
  },
  {
    label: '发布日期',
    field: 'releaseDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入发布日期!'},
      ];
     },
  },
  {
    label: '启用日期',
    field: 'startDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入启用日期!'},
      ];
     },
  },
  {
    label: '废止日期',
    field: 'annulmentDate',
    component: 'DatePicker',
  },
  {
    label: '是否现行',
    field: 'currentOrNot',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"yn"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入是否现行!'},
      ];
     },
  },
  {
    label: '附件',
    field: 'doc',
    component: 'JUpload',
    componentProps:{
    },
  },
  {
    label: '复查时间',
    field: 'reviewDate',
    component: 'DatePicker',
  },
  {
    label: '辨识人',
    field: 'recognizePeople',
    component: 'JSelectUser',
    componentProps:{
      labelKey:'realname',
    },
  },
  {
    label: '辨识日期',
    field: 'recognizeDate',
    component: 'DatePicker',
  },
  {
    label: '来源',
    field: 'source',
    component: 'Input',
  },
  {
    label: '适用部门',
    field: 'applicableDepartment',
    component: 'JSelectDept',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入适用部门!'},
      ];
     },
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"normalOrStop"
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
	field: 'id',
	component: 'Input',
	show: false
  },
];

//子表列表数据
export const tbLawsRegulationsClauseColumns: BasicColumn[] = [
  {
    title: '辨识内容',
    align:"center",
    dataIndex: 'content'
  },
  {
    title: '图片',
    align:"center",
    dataIndex: 'img',
    customRender:render.renderImage,
  },
];
//子表表单数据
export const tbLawsRegulationsClauseFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '辨识内容',
    field: 'content',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入辨识内容!'},
      ];
    },
  },
  {
    label: '图片',
    field: 'img',
     component: 'JImageUpload',
     componentProps:{
      },
  },
];

// 高级查询数据
export const superQuerySchema = {
  number: {title: '法规编号',order: 0,view: 'text', type: 'string',},
  name: {title: '文件名称',order: 1,view: 'text', type: 'string',},
  type: {title: '法律法规分类',order: 2,view: 'radio', type: 'string',},
  coerciveDegree: {title: '强制程度',order: 3,view: 'radio', type: 'string',},
  issuingAuthority: {title: '发布机构',order: 4,view: 'text', type: 'string',},
  releaseDate: {title: '发布日期',order: 5,view: 'date', type: 'string',},
  startDate: {title: '启用日期',order: 6,view: 'date', type: 'string',},
  annulmentDate: {title: '废止日期',order: 7,view: 'date', type: 'string',},
  currentOrNot: {title: '是否现行',order: 8,view: 'radio', type: 'string',},
  doc: {title: '附件',order: 9,view: 'file', type: 'string',},
  reviewDate: {title: '复查时间',order: 10,view: 'date', type: 'string',},
  recognizePeople: {title: '辨识人',order: 11,view: 'sel_user', type: 'string',},
  recognizeDate: {title: '辨识日期',order: 12,view: 'date', type: 'string',},
  source: {title: '来源',order: 13,view: 'text', type: 'string',},
  applicableDepartment: {title: '适用部门',order: 14,view: 'sel_depart', type: 'string',},
  status: {title: '状态',order: 15,view: 'radio', type: 'string',},
};
